import js from "@eslint/js";
import globals from "globals";
import pluginVue from "eslint-plugin-vue";
import prettier from "eslint-config-prettier";
import { defineConfig } from "eslint/config";

export default defineConfig([
  {
    files: ["**/*.{js,mjs,cjs,vue}"],
    languageOptions: {
      globals: { ...globals.browser, ...globals.node },
      ecmaVersion: 2022,
      sourceType: "module",
    },
    plugins: { vue: pluginVue },
    extends: [js.configs.recommended, pluginVue.configs["flat/recommended"], prettier],
    rules: {
      "no-unused-vars": [
        "warn",
        {
          // 允许以 _ 符号开头的变量未被使用
          argsIgnorePattern: "^_",
          varsIgnorePattern: "^_",
          caughtErrorsIgnorePattern: "^_",
        },
      ],
      // "no-console": "warn",
      "no-debugger": "warn",
      "vue/multi-word-component-names": "off",
      "vue/no-unused-vars": "warn",
      "vue/no-unused-refs": "warn",
      "vue/no-unused-properties": "warn",
      "prefer-const": [
        "error",
        {
          destructuring: "all",
          ignoreReadBeforeAssign: false, // 允许先声明后赋值的情况使用 let
        },
      ],
    },
  },
]);
